<template>
  <div id="consumer-detail">
    <div class="g-form-title">消费者详情</div>
    <table class="g-form-detail-item" border="1">
      <tr>
        <td>消费者名称</td>
        <td>{{consumer.consumerName}}</td>
      </tr>
      <tr>
        <td>消费者编码</td>
        <td>{{consumer.consumerNameCode}}</td>
      </tr>
      <tr>
        <td>调用次数</td>
        <td>{{consumer.invoke}}</td>
      </tr>
      <tr>
        <td>状态</td>
        <td>{{consumer.status|statusFormatter}}</td>
      </tr>
      <tr>
        <td>是否启用</td>
        <td>{{consumer.isEnable|isEnableFormatter}}</td>
      </tr>
    </table>
    <el-button type="primary" @click="closeButton" class="pull-right">关闭</el-button>
    <div clearfix></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      consumer: {}
    }
  },
  filters: {
    statusFormatter(value) {
      return ['草稿', '已发布'][value]
    },
    isEnableFormatter(value) {
      return value?'启用':'禁用'
    }
  },
  methods: {
    load(consumer) {
      this.consumer = consumer
    },
    closeButton() {
      this.$emit('close')
    }
  }
}
</script>
<style lang="scss">
#consumer-detail {
  padding: 20px;
  table.g-form-detail-item td:nth-child(2n+1) {
    width: 140px;
  }
}
</style>